package li.brauch.semesterarbeit.radio.views.util;

import java.net.MalformedURLException;
import java.net.URL;

import li.brauch.semesterarbeit.radio.RadioPlugin;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;

public class ImageStore {
	
	public final static Image WARNING = createImage("warning.png");
	public final static Image ERROR = createImage("error.png");
	public final static Image CHECK = createImage("check.png");
	
	public final static Image NO_COVER = createImage("nocover.png");
	
	public final static Image MUTE = createImage("mute.png");
	public final static Image MUTE_ROLLOVER = createImage("mute_rollover.png");
	public final static Image MUTE_CLICK = createImage("mute_click.png");
	
	public final static Image AUDIBLE = createImage("audible.png");
	public final static Image AUDIBLE_ROLLOVER = createImage("audible_rollover.png");
	public final static Image AUDIBLE_CLICK = createImage("audible_click.png");
	
	public final static Image LOVE = createImage("love.png");
	public final static Image LOVE_ROLLOVER = createImage("love_rollover.png");
	public final static Image LOVE_CLICK = createImage("love_click.png");
	
	public final static Image BAN = createImage("ban.png");
	public final static Image BAN_ROLLOVER = createImage("ban_rollover.png");
	public final static Image BAN_CLICK = createImage("ban_click.png");
	
	public final static Image STOP = createImage("stop.png");
	public final static Image STOP_ROLLOVER = createImage("stop_rollover.png");
	public final static Image STOP_CLICK = createImage("stop_click.png");
	
	public final static Image SKIP = createImage("skip.png");
	public final static Image SKIP_ROLLOVER = createImage("skip_rollover.png");
	public final static Image SKIP_CLICK = createImage("skip_click.png");
	
	public final static Image BUY = createImage("buy.png");
	public final static Image BUY_ROLLOVER = createImage("buy_rollover.png");
	public final static Image BUY_CLICK = createImage("buy_click.png");
	
	public final static Image PLAY = createImage("play.png");
	public final static Image PLAY_ROLLOVER = createImage("play_rollover.png");	
	public final static Image PLAY_CLICK = createImage("play_click.png");
	
	public final static Image PAUSE = createImage("pause.png");
	public final static Image PAUSE_ROLLOVER = createImage("pause_rollover.png");
	public final static Image PAUSE_CLICK = createImage("pause_click.png");
	
	public static void dispose() {
		WARNING.dispose();
		ERROR.dispose();
		CHECK.dispose();
		NO_COVER.dispose();
		
		MUTE.dispose();
		MUTE_ROLLOVER.dispose();
		MUTE_CLICK.dispose();
		
		AUDIBLE.dispose();		
		AUDIBLE_ROLLOVER.dispose();
		AUDIBLE_CLICK.dispose();
		
		LOVE.dispose();
		LOVE_ROLLOVER.dispose();
		LOVE_CLICK.dispose();
		
		BAN.dispose();
		BAN_ROLLOVER.dispose();
		BAN_CLICK.dispose();
		
		STOP.dispose();
		STOP_ROLLOVER.dispose();
		STOP_CLICK.dispose();
		
		SKIP.dispose();
		SKIP_ROLLOVER.dispose();		
		SKIP_CLICK.dispose();
		
		BUY.dispose();
		BUY_ROLLOVER.dispose();
		BUY_CLICK.dispose();
		
		PLAY.dispose();
		PLAY_ROLLOVER.dispose();		
		PLAY_CLICK.dispose();
		
		PAUSE.dispose();
		PAUSE_ROLLOVER.dispose();
		PAUSE_CLICK.dispose();
	}
	
	public static Image createImage(URL url) {
		return ImageDescriptor.createFromURL(url).createImage();
	}
	
	private static Image createImage(String relativePath) {
		Image image;
		try {
			image = ImageDescriptor.createFromURL(new URL(RadioPlugin
				.getDefault()
				.getBundle()
				.getEntry("/"),
				"res/" + relativePath)).createImage();
			
			return image;
			
		} catch (final MalformedURLException e) {
		
		}
		
		return null;
	}
}
